#
# PHP Dockerfile
# 安装常用扩展
#
 
# Pull  base image.
FROM php:5.6-fpm
 
MAINTAINER Will "Will.zhou@xiaoxiongyouxi.com"
 
#更换源 http://mirrors.163.com/.help/debian.html
COPY sources.list /etc/apt/sources.list
 
# Install modules
# composer需要先安装zip
RUN \
apt-get update \
&& apt-get install -y --no-install-recommends \
libmcrypt-dev \
libssl-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng12-dev \
libmagickwand-dev \
wget \
&& apt-get autoremove \
&& apt-get clean \
&& rm -r /var/lib/apt/lists/*
 
# install php modules
# pecl install php modules
RUN \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install gd \
&& docker-php-ext-install mysqli mysql mcrypt pdo_mysql zip
 
#通过pecl安装扩展
RUN \
cd /tmp \
&& wget http://pecl.php.net/get/redis-3.1.4.tgz \
&& tar -xvf redis-3.1.4.tgz \
&& cd redis-3.1.4 && phpize && ./configure && make && make install \
#pecl install redis \
&& echo "extension=redis.so" > /usr/local/etc/php/conf.d/redis.ini \
#&& pecl install channel://pecl.php.net/msgpack-0.5.7 \
#&& echo "extension=msgpack.so" > /usr/local/etc/php/conf.d/msgpack.ini \
#&& pecl install mongodb \
&& cd /tmp \
&& wget http://pecl.php.net/get/mongodb-1.3.4.tgz \
&& tar -xvf mongodb-1.3.4.tgz \
&& cd mongodb-1.3.4 && phpize && ./configure && make && make install \
&& echo "extension=mongodb.so" > /usr/local/etc/php/conf.d/mongodb.ini
#&& pecl clear-cache
 
# composer 
# composer中国镜像
# 注意：需要先安装lumen，在安装laravel，否则报错
# 不应在镜像中绑定国内的镜像，因为镜像可能会用到国外的服务器
# 测试国内的容易抽风。。
#&& curl -sS https://getcomposer.org/installer -o /composer.php \
#&& php composer.php \
#&& mv composer.phar /usr/local/bin/composer \
#&& composer config -g repo.packagist composer http://packagist.phpcomposer.com \
#&& rm -f composer.php \
#&& chmod 755 /usr/local/bin/composer \
#&& php -r "if (hash('SHA384', file_get_contents('composer-setup.php')) === 'fd26ce67e3b237fffd5e5544b45b0d92c41a4afe3e3f778e942e43ce6be197b9cdc7c251dcde6e2a52297ea269370680') { echo 'Installer verified';  } else { echo 'Installer corrupt'; unlink('composer-setup.php');  }" \
RUN cd / \
&& php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php \
&& php composer-setup.php  --filename=composer  --install-dir=/usr/local/bin/ \
&& rm composer-setup.php \
&& composer clearcache \
&& composer clear-cache
 
 
# 解决时区问题
ENV TZ "Asia/Shanghai"
 
# 终端设置
# 执行php-fpm时，默认值是dumb，这时在终端操作时可能会出现：terminal is not fully functional
ENV TERM xterm
 
# Define mountable directories.
VOLUME /var/www
 
# 工作目录
WORKDIR /var/www
 
EXPOSE 9000